/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cr.ac.una.sive.entidad;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author claribel
 */
@Entity
@Table(name = "REGISTRO_HORARIO", catalog = "", schema = "UNA_SIVE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RegistroHorario.findAll", query = "SELECT r FROM RegistroHorario r"),
    @NamedQuery(name = "RegistroHorario.findByIdRegistroHorario", query = "SELECT r FROM RegistroHorario r WHERE r.idRegistroHorario = :idRegistroHorario"),
    @NamedQuery(name = "RegistroHorario.findByEstacionamiento", query = "SELECT r FROM RegistroHorario r WHERE r.estacionamiento = :estacionamiento")})
public class RegistroHorario implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "SQREGISTRO_HORARIO")
    @SequenceGenerator(name="SQREGISTRO_HORARIO", sequenceName = "SQ_REGISTRO_HORARIO",allocationSize=1)
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_REGISTRO_HORARIO", nullable = false, precision = 0, scale = -127)
    private BigDecimal idRegistroHorario;
    @Size(max = 100)
    @Column(name = "ESTACIONAMIENTO", length = 100)
    private String estacionamiento;
    @JoinColumn(name = "USUARIO", referencedColumnName = "ID_USUARIO")
    @ManyToOne(fetch = FetchType.EAGER)
    private Usuario usuario;
    @OneToMany(mappedBy = "registroHorario", fetch = FetchType.EAGER)
    private Collection<HorarioUsuario> horarioUsuarioCollection;

    public RegistroHorario() {
    }

    public RegistroHorario(BigDecimal idRegistroHorario) {
        this.idRegistroHorario = idRegistroHorario;
    }

    public BigDecimal getIdRegistroHorario() {
        return idRegistroHorario;
    }

    public void setIdRegistroHorario(BigDecimal idRegistroHorario) {
        this.idRegistroHorario = idRegistroHorario;
    }

    public String getEstacionamiento() {
        return estacionamiento;
    }

    public void setEstacionamiento(String estacionamiento) {
        this.estacionamiento = estacionamiento;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    @XmlTransient
    public Collection<HorarioUsuario> getHorarioUsuarioCollection() {
        return horarioUsuarioCollection;
    }

    public void setHorarioUsuarioCollection(Collection<HorarioUsuario> horarioUsuarioCollection) {
        this.horarioUsuarioCollection = horarioUsuarioCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRegistroHorario != null ? idRegistroHorario.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RegistroHorario)) {
            return false;
        }
        RegistroHorario other = (RegistroHorario) object;
        if ((this.idRegistroHorario == null && other.idRegistroHorario != null) || (this.idRegistroHorario != null && !this.idRegistroHorario.equals(other.idRegistroHorario))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cr.ac.una.sive.entidad.RegistroHorario[ idRegistroHorario=" + idRegistroHorario + " ]";
    }
    
}
